package com.decent.common.validator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 校验文件
 *
 * @author: wangyan
 * @date: 2021/12/16
 */
@Documented
@Retention(RUNTIME)
@Constraint(validatedBy = CheckFileNotNullValidator.class)
@Repeatable(CheckFileNotNull.List.class)
@Target({METHOD, ANNOTATION_TYPE, CONSTRUCTOR, TYPE, FIELD})
public @interface CheckFileNotNull {
    String message() default "请选择文件！";

    Class<?>[] groups() default {};

    @SuppressWarnings("unused") Class<? extends Payload>[] payload() default {};

    /**
     * Defines several {@link CheckFileNotNull} annotations on the same element.
     *
     * @see CheckFileNotNull
     */
    @Documented
    @Retention(RUNTIME)
    @Target({METHOD, ANNOTATION_TYPE, CONSTRUCTOR, TYPE, FIELD})
    @interface List {
        CheckFileNotNull[] value();
    }
}
